package com.mochasoft.shangchm.analyzer;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class LineAnalyzer implements Analyzer {

	public boolean isBad(TreeSet group) {
		Set fenhang = fenhang(group);
		if(fenhang.size()>=4 && fenhang.size()<=5){
			System.out.println("分行法:"+fenhang+" size = "+fenhang.size());
			return false;
		}else{
			return true;
		}	
	}
	
	private Set fenhang(Set group){
		Set fenhang = new TreeSet();
		for (Iterator iter = group.iterator(); iter.hasNext();) {
			fenhang.add(findLine((Integer) iter.next()));
		}
		return fenhang;
	}
	
	private int findLine(int number) {
		int i = 0;
		switch (number) {
		case 1:
			i = 1;
			break;
		case 2:

			i = 1;
			break;

		case 3:

			i = 1;
			break;

		case 4:

			i = 1;
			break;
		case 5:

			i = 1;
			break;
		case 6:

			i = 1;
			break;
		case 7:

			i = 2;
			break;
		case 8:

			i = 2;
			break;
		case 9:

			i = 2;
			break;
		case 10:

			i = 2;
			break;
		case 11:

			i = 2;
			break;
		case 12:

			i = 2;
			break;
		case 13:

			i = 3;
			break;
		case 14:

			i = 3;
			break;
		case 15:

			i = 3;
			break;
		case 16:

			i = 3;
			break;
		case 17:

			i = 3;
			break;
		case 18:

			i = 3;
			break;
		case 19:

			i = 4;
			break;
		case 20:

			i = 4;
			break;
		case 21:

			i = 4;
			break;
		case 22:

			i = 4;
			break;
		case 23:

			i = 4;
			break;
		case 24:

			i = 4;
			break;
		case 25:

			i = 5;
			break;
		case 26:

			i = 5;
			break;
		case 27:

			i = 5;
			break;
		case 28:

			i = 5;
			break;
		case 29:

			i = 5;
			break;
		case 30:

			i = 5;
			break;
		case 31:

			i = 6;
			break;
		case 32:

			i = 6;
			break;
		case 33:
			i = 6;
			break;
		}
		return i;

	}

}
